﻿using System;
using Orchard.ContentManagement;
using Orchard.ContentManagement.Utilities;

namespace Whatsnexx.Models
{
    public class WhatsnexxSettingsPart : ContentPart<WhatsnexxSettingsPartRecord>
    {
        /*private readonly ComputedField<string> _password = new ComputedField<string>();
        
        public ComputedField<string> PasswordField
        {
            get { return _password; }
        }*/

        public string TicketBusUrl
        {
            get { return Record.TicketBusUrl; }
            set { Record.TicketBusUrl = value; }
        }

        public string AccountId
        {
            get { return Record.AccountId; }
            set { Record.AccountId = value; }
        }

        public string UserName
        {
            get { return Record.UserName; }
            set { Record.UserName = value; }
        }

        public string Password
        {
            get { return Record.Password; }
            set { Record.Password = value; }
        }

        public bool IsValid()
        {
            Guid bufferAccountId;
            return !String.IsNullOrWhiteSpace(Record.AccountId)
                   && Guid.TryParse(Record.AccountId, out bufferAccountId)
                   && !String.IsNullOrWhiteSpace(Record.UserName)
                   && !String.IsNullOrWhiteSpace(Record.Password);
        }

    }
}